<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>表格内的定位</title>
    <meta http-equiv="X-UA-Compatible" content="chrome=1" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta name="author" content="yb">
    <meta name="keywords" content="关键词" />
    <meta name="description" content="描述" />
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
    <meta http-equiv="Expires" content="0">
    <!-- <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /> -->
    <script src="https://cdn.bootcss.com/jquery/1.10.1/jquery.min.js"></script>
    <link rel="stylesheet" href="../style/css/base.css">
    <style>
        body {
            padding: 0;
            margin: 0;
        }
    
        /* 设置滚动条的样式 */
    
        ::-webkit-scrollbar {
            width: 10px;
            background-color: #eee;
        }
    
        /* 滚动槽 */
        ::-webkit-scrollbar-track {
            -webkit-box-shadow: inset006pxrgba(0, 0, 0, 0.3);
            border-radius: 10px;
        }
    
        /* 滚动条滑块 */
        ::-webkit-scrollbar-thumb {
            border-radius: 5px;
            background: rgba(0, 0, 255, 0.2);
            -webkit-box-shadow: inset006pxrgba(0, 0, 0, 0.5);
        }
    
        ::-webkit-scrollbar-thumb:window-inactive {
            background: rgba(0, 0, 0, 0.4);
        }
        
        /* #tableBox{
            width: 600px;
            height: 200px;
            position: relative;
        } */
        #tableDiv{
            width: 600px;
            height: 200px;
            overflow-x: auto;
            overflow-y: auto;
            margin: 20px auto auto 20px;
            background-color: #ffe4c4;
            position: relative;
            padding-top: 40px;
        }
        table{
            width: 1200px;
            border-spacing: 0;
            border-collapse: collapse;
            position: static;
        }
        tbody{
            position: static;
        }
        tr{
            height: 40px;
            /* position: relative; */
            position: static;
        }
        td{
            width: 100px;
            height: 40px;
            padding: 2px 5px;
            border: 1px solid #aaa;
            text-align: center;
        }
        tr>td:nth-child(1),
        tr>td:nth-child(2),
        tr>td:nth-child(3),
        tr>td:last-child{
            position: absolute;
            background-color: #1bbaff;
            color: #ffffff;
            z-index: 2;
            /* top: 0px; */
        }
        tr>td:nth-child(1){
            left: 0;
        }
        tr>td:nth-child(2){
            left: 100px;
        }
        tr>td:nth-child(3){
            left: 200px;
        }
        tr>td:last-child{
            left: 500px;
            /* right: 0px; */
        }

        tr:first-child{
            /* position: static; */
        }
        thead{
            width: 1200px;
            height: 40px;
            position: absolute;
            top: 0;
            z-index: 9;
        }
        thead td{
            width: 100px;
        }
        thead tr:first-child{
            background-color: #0fa;
        }
        thead>tr:first-child>td:nth-child(1),
        thead>tr:first-child>td:nth-child(2),
        thead>tr:first-child>td:nth-child(3),
        thead>tr:first-child>td:last-child,{
            z-index: 3;
        }
    </style>
</head>
<body>
    <div id="tableBox">
    <div id="tableDiv">
        <table>
            <thead>
                <tr>
                    <td>项目名称</td>
                    <td>项目号</td>
                    <td>人员名称</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>1</td>
                    <td>2</td>
                    <td>3</td>
                    <td>4</td>
                    <td>5</td>
                    <td>6</td>
                    <td>7</td>
                    <td>8</td>
                    <td></td>
                    <td>项目状态</td>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>ali1</td>
                    <td>9377</td>
                    <td>王小二</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td></td>
                    <td>已完成</td>
                </tr>
                <tr>
                    <td>ali1</td>
                    <td>9377</td>
                    <td>王小二</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td></td>
                    <td>已完成</td>
                </tr>
                <tr>
                    <td>ali1</td>
                    <td>9377</td>
                    <td>王小二</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td></td>
                    <td>已完成</td>
                </tr>
                <tr>
                    <td>ali1</td>
                    <td>9377</td>
                    <td>王小二</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td></td>
                    <td>已完成</td>
                </tr>
            </tbody>
        </table>
    </div></div>
</body>
<script>

</script>